package com.lzdongrui.backend.controller;

import com.lzdongrui.backend.domain.FileResources;
import com.lzdongrui.backend.service.IFileResourcesService;
import com.lzdongrui.common.core.controller.BaseController;
import com.lzdongrui.common.core.domain.AjaxResult;
import com.lzdongrui.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 文件资源 Controller
 *
 * @author wyh
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/backend/resources")
public class FileResourcesController extends BaseController {
    @Autowired
    private IFileResourcesService iFileResourcesService;


    /**
     * 获取文件资源详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(iFileResourcesService.selectFileResourcesById(id));
    }

    /**
     * 查询文件资源列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FileResources fileResources) {
        startPage();
        List<FileResources> list = iFileResourcesService.selectFileResourcesList(fileResources);
        return getDataTable(list);
    }

    /**
     * 查询文件资源列表
     */
    @GetMapping("/check-list")
    public TableDataInfo checkList(FileResources fileResources) {
        List<FileResources> list = iFileResourcesService.checkList(fileResources);
        return getDataTable(list);
    }

    /**
     * 新增文件资源
     */
    @PostMapping
    public AjaxResult add(@RequestBody FileResources fileResources) {
        return toAjax(iFileResourcesService.insertFileResources(fileResources));
    }

    /**
     * 修改文件资源
     */
    @PutMapping
    public AjaxResult edit(@RequestBody FileResources fileResources) {
        return toAjax(iFileResourcesService.updateFileResources(fileResources));
    }

    /**
     * 删除文件资源
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iFileResourcesService.deleteFileResourcesByIds(ids));
    }


}
